#ifndef MESSAGE_H
#define MESSAGE_H

#define TO "TO"
#define FROM "FROM"
#define CMD_TYPE "CMD_TYPE"
#define BODY "BODY"
#define TS "TS"


#include <QJsonObject>
#include <QJsonDocument>

enum CmdType: int{
    Login,
    Chat,
    Logout
};

class Message
{
private:
    CmdType cmdType;
    QString to;
    QString from;
    QString body;
    QString ts;


public:
    Message();
    Message(CmdType cmdType, const QString &to, const QString &from, const QString &body);

    QByteArray toByteArray() const;
    QString toString() const;
    static Message* fromByteArray(QByteArray&);

    CmdType getCmdType() const;
    QString getTo() const;
    QString getFrom() const;
    QString getBody() const;

    void setFrom(const QString &newFrom);
};

#endif // MESSAGE_H
